package com.srpingde.hhh.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;

import com.springde.hhh.R;
import com.srpingde.hhh.application.HhhApp;
import com.srpingde.hhh.bean.HHHMeiTuDataBean;

public class MeiTuAdapter extends BaseAdapter{
	Context context;
	ArrayList<HHHMeiTuDataBean> list;
	public MeiTuAdapter(ArrayList<HHHMeiTuDataBean> list, 
			Context context) {
		super();
		this.list = list;
		this.context = context;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}
	private void itemLayout(TextView imageView){
		int wh = (int) (HhhApp.getInstance().getDisplayHightAndWightPx()[1]/4);
		RelativeLayout.LayoutParams layoutParams = (LayoutParams) imageView.getLayoutParams();
		layoutParams.height = wh;
		layoutParams.width = wh;
		imageView.setLayoutParams(layoutParams);
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		fenLeiHolder holder = null;
		if(convertView == null){
			holder = new fenLeiHolder();
			convertView = LayoutInflater.from(context).inflate(R.layout.textview_layout, null);
			holder.icon = (TextView) convertView.findViewById(R.id.fenlei_item_tv);
			convertView.setTag(holder);
		}else{
			holder = (fenLeiHolder) convertView.getTag();
		}
		itemLayout(holder.icon);
		//holder.icon.setBackgroundResource(images[arg0]);
		holder.icon.setText(list.get(position).getName());
		return convertView;
	}
	class fenLeiHolder{
		TextView icon;
	}
	
}
